package com.wyw.hemerocallis.service.hystrix;

import com.alibaba.fastjson.JSON;
import com.wyw.hemerocallis.service.AuthorityFeignClient;
import com.wyw.hemerocallis.vo.JwtToken;
import com.wyw.hemerocallis.vo.UsernameAndPassword;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * AuthorityFeignClient后备，没有对应的错误信息
 *
 * @author Mr Wu    yewen.wu.china@gmail.com
 * <p>
 * Update History:
 * Author        Time            Content
 */
@Slf4j
@Component
public class AuthorityFeignClientFallback implements AuthorityFeignClient {

    /**
     * fallback只能保证数据有返回，但是无法看到具体什么错误
     */
    @Override
    public JwtToken getTokenByFeign(UsernameAndPassword usernameAndPassword) {
        log.info("Authority feign client get token by feign request error "  +
              "(Hystrix Fallback): [{}]", JSON.toJSONString(usernameAndPassword));
        return new JwtToken("wyw");
    }
}
